package com.example.mytestdemo.car.appwidget

import android.content.Intent
import android.text.TextUtils
import android.util.Log
import com.example.mytestdemo.BaseViewBindActivity
import com.example.mytestdemo.R
import com.example.mytestdemo.databinding.ActivitySimpleAppwidgetBinding

/**
 * @author tgw
 * @date 2022/9/13
 * @describe
 */
class SimpleAppWidgetActivity : BaseViewBindActivity<ActivitySimpleAppwidgetBinding>() {
    override fun getLayoutInflateId(): Int {
        return R.layout.activity_simple_appwidget
    }

    override fun initData() {}
    override fun initUI() {
        val param = intent.getStringExtra("param")
        if (!TextUtils.isEmpty(param)) {
            mBind.bt.setText(param)
        }
        mBind.bt.setOnClickListener {
            Log.d("SimpleWidgetProvide.TAG", "setOnClickListener: ")
            sendBroadcast(Intent("android.appwidget.action.APPWIDGET_UPDATE"))

            var intent = Intent(this, UpdateService::class.java)
            intent.putExtra("id", 5)
            startService(intent)
        }
    }
}